#!/bin/bash
# 刷新 macOS 应用图标缓存

set -e

echo "=========================================="
echo " 刷新 LimeReader 图标"
echo "=========================================="
echo ""

APP="/Applications/LimeReader.app"

if [ ! -d "$APP" ]; then
    echo "[ERROR] 未找到应用程序: $APP"
    exit 1
fi

echo "[1] 清理图标缓存..."
# 删除图标缓存
sudo rm -rf /Library/Caches/com.apple.iconservices.store 2>/dev/null || true
rm -rf ~/Library/Caches/com.apple.iconservices.store 2>/dev/null || true

echo "[2] 触碰应用程序包..."
# 更新应用的修改时间
sudo touch "$APP"
sudo touch "$APP/Contents/Info.plist"

echo "[3] 重启 Dock 和 Finder..."
# 重启相关服务
killall Dock
killall Finder

echo ""
echo "=========================================="
echo " 完成！"
echo "=========================================="
echo ""
echo "图标缓存已刷新，请稍等几秒让 Dock 重新加载"
echo ""

